import pandas as pd
from django.core.files.storage import FileSystemStorage

class DataProcessor:
    @staticmethod
    def process_excel(file_path):
        """
        处理Excel文件并返回清洗后的数据
        :param file_path: Excel文件路径
        :return: 处理后的DataFrame
        """
        try:
            df = pd.read_excel(file_path)
            # 这里可以添加数据清洗逻辑
            return df
        except Exception as e:
            print(f"处理Excel文件时出错: {e}")
            return None

    @staticmethod
    def save_uploaded_file(uploaded_file):
        """
        保存上传的文件并返回文件路径
        :param uploaded_file: 上传的文件对象
        :return: 保存后的文件路径
        """
        fs = FileSystemStorage()
        filename = fs.save(uploaded_file.name, uploaded_file)
        return fs.path(filename)